package me.softwareengineer.guice.rendering.domain;

import java.util.List;

import me.softwareengineer.guice.rendering.listener.EndDefinitionDescriptionEvent;
import me.softwareengineer.guice.rendering.listener.Listener;
import me.softwareengineer.guice.rendering.listener.StartDefinitionDescriptionEvent;

/**
 * Represents a definition description. All definition descriptions 
 * are contained in  {@link DefinitionListElement}s and can contain text, embedded 
 * lists or an embedded document.
 *
 *<p>
 * Event: the following event is generated during {@link #render(Listener)}:
 * <ul>
 * <li>{@link EndDefinitionDescriptionEvent}</li>
 * <li>{@link StartDefinitionDescriptionEvent}</li>
 * </ul>
 * </p>
 *
 * <pre>
 * This class is thread-safe and can be cached/re-used and used concurrently.
 * </pre>
 * 
 * @author yadtahir
 * @version 1.0
 *
 */
//This class is marked as final as we want to make it immutable as much as possible
public final class DefinitionDescriptionElement extends Element {

	/**
	 * Constructs a definition description
	 * 
	 * @param children
	 *            the children of element
	 * @see HasChildren
	 */
	public DefinitionDescriptionElement(List<Element> children) {
		super(children);
	}

	/**
	 * {@inheritDoc}
	 * <p>
	 * This method triggers the following event:
	 * <ul>
	 * 	<li>EndDefinitionDescriptionEvent</li>
	 * </ul> 
	 * </p>
	 * 
	 * @see EndDefinitionDescriptionEvent
	 *
	 */
	@Override
	protected void afterElement(Listener listener) {
		EndDefinitionDescriptionEvent e = new EndDefinitionDescriptionEvent();
		listener.onEvent(e);
	}

	/**
	 * {@inheritDoc}
	 * 
	 * <p>
	 * This method triggers the following event:
	 * <ul>
	 * 	<li>StartefinitionDescriptionEvent</li>
	 * </ul> 
	 * </p>
	 * 
	 * @see StartDefinitionDescriptionEvent
	 */
	@Override
	protected void beforeElement(Listener listener) {
		StartDefinitionDescriptionEvent e = new StartDefinitionDescriptionEvent();
		listener.onEvent(e);
	}

}
